package algotithm.weekendrace.leetcode237.test2;

import java.util.Arrays;

/**
 * @author zhouyanxiang
 * @Date 2021-04-2021/4/18-10:23
 */
public class Solution {


    public static void main(String[] args) {
        Solution solution = new Solution();
    }


    public int maxIceCream(int[] costs, int coins) {
        int n = costs.length;
        Arrays.sort(costs);
        int res = 0;
        for (int i = 0; i < n; i++) {
            if (coins - costs[i] >= 0) {
                res++;
                coins = coins - costs[i];
            } else {
                continue;
            }
        }
        return res;
    }
}
